package com.weijian.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.weijian.dal.dataobject.Article;
import com.weijian.mapper.ArticleMapper;
import com.weijian.service.ArticleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
@Slf4j
public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article> implements ArticleService {
    @Override
    public List<Article> listUpdatedSince(LocalDateTime sinceTime) {
        LambdaQueryWrapper<Article> wrapper = new LambdaQueryWrapper<Article>()
                .ge(Article::getUpdateTime, sinceTime)
                .select();
        // 手动包含逻辑删除记录
        wrapper.and(w -> w.isNull(Article::getDeleted).or().eq(Article::getDeleted, false).or().eq(Article::getDeleted, true));
        return baseMapper.selectList(wrapper);
    }
}
